// 接口

package main

import "fmt"

type animals interface {
	eat(string) // 需要实现所有的方法 才能为接口类型
}

type cat struct {
	name string
}

type dog struct {
	name string
}

func newCat(name string) *cat {
	return &cat{
		name: name,
	}
}

func newDog(name string) *dog {
	return &dog{
		name: name,
	}
}

func (c cat) eat(food string) {
	fmt.Printf("猫吃:%s\n", food)
}

func (d dog) eat(food string) {
	fmt.Printf("狗吃:%s\n", food)
}

func main() {
	c1 := newCat("ll")
	c1.eat("鱼")
	d1 := newDog("JJ")
	d1.eat("骨头")
}
